package org.awenlice.playerdailyshop.util;

import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

public class InventoryHelper {
    /**
     * 将物品添加到玩家背包，若背包满了则生成掉落物
     */
    public static void addItemToPlayerInventory(Player player, ItemStack stack) {
        if (!player.getInventory().add(stack)) {
            // 如果背包已满，生成掉落物
            player.drop(stack, false); // false 表示不随机掉落位置
        }
    }
}